(function (vc, vm) {

    vc.extends({
        data: {
            auditGoldWithdrawalInfo: {
                gwId: '',
                goldId: '',
                goldName: '',
                communityId: '',
                amount: '',
                applyAmount:'',
                applyUserName: '',
                applyUserTel: '',
                remark: '',
                state: '',
                stateMsg: '',
                bankNum:'',
                bankNumName:'',
                bankName:'',
            }
        },
        _initMethod: function () {

        },
        _initEvent: function () {
            vc.on('auditGoldWithdrawal', 'openAuditGoldWithdrawalModal', function (_params) {
                $that.refreshAuditGoldWithdrawalInfo();
                $('#auditGoldWithdrawalModel').modal('show');
                vc.copyObject(_params, $that.auditGoldWithdrawalInfo);
                $that.auditGoldWithdrawalInfo.applyAmount = _params.amount;
                $that.auditGoldWithdrawalInfo.state = '';
                $that.auditGoldWithdrawalInfo.stateMsg = '';
                $that.auditGoldWithdrawalInfo.communityId = vc.getCurrentCommunity().communityId;
            });
        },
        methods: {
            auditGoldWithdrawalValidate: function () {
                return vc.validate.validate({
                    auditGoldWithdrawalInfo: $that.auditGoldWithdrawalInfo
                }, {
                    'auditGoldWithdrawalInfo.goldId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "金币ID不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "30",
                            errInfo: "金币ID不能超过30"
                        },
                    ],
                   
                    'auditGoldWithdrawalInfo.applyAmount': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "提现金额不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "10",
                            errInfo: "提现金额不能超过10"
                        },
                    ],
                    'auditGoldWithdrawalInfo.state': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "W不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "12",
                            errInfo: "W不能超过12"
                        },
                    ],
                    'auditGoldWithdrawalInfo.stateMsg': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "审核说明不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "512",
                            errInfo: "审核说明不能超过512"
                        },
                    ],
                    'auditGoldWithdrawalInfo.gwId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "编号不能为空"
                        }]

                });
            },
            auditGoldWithdrawal: function () {
                if (!$that.auditGoldWithdrawalValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }

                vc.http.apiPost(
                    '/gold.auditGoldWithdrawal',
                    JSON.stringify($that.auditGoldWithdrawalInfo),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            $('#auditGoldWithdrawalModel').modal('hide');
                            vc.emit('goldWithdrawal', 'listGoldWithdrawal', {});
                            return;
                        }
                        vc.message(_json.msg);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');

                        vc.message(errInfo);
                    });
            },
            refreshAuditGoldWithdrawalInfo: function () {
                $that.auditGoldWithdrawalInfo = {
                    gwId: '',
                    goldId: '',
                    goldName: '',
                    communityId: '',
                    amount: '',
                    applyAmount:'',
                    applyUserName: '',
                    applyUserTel: '',
                    remark: '',
                    state: '',
                    stateMsg: '',
                    bankNum:'',
                    bankNumName:'',
                    bankName:'',

                }
            }
        }
    });

})(window.vc, window.$that);
